package com.cmcc.passenger.ui.profile

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.cmcc.shared.adapter.MultiItemViewBinder
import com.cmcc.passenger.R
import com.cmcc.passenger.data.entity.FavoriteAddress
import com.cmcc.passenger.databinding.ListItemAddressBinding

class AddressViewBinder : MultiItemViewBinder<FavoriteAddress, AddressViewHolder>(FavoriteAddress::class.java) {
    override fun createViewHolder(parent: ViewGroup): RecyclerView.ViewHolder {
        return AddressViewHolder(ListItemAddressBinding.inflate(LayoutInflater.from(parent.context),parent,false))
    }

    override fun bindViewHolder(model: FavoriteAddress, viewHolder: AddressViewHolder) {
        viewHolder.bind()
    }

    override fun getItemType(): Int {
        return R.layout.list_item_address
    }

    override fun areContentsTheSame(oldItem: FavoriteAddress, newItem: FavoriteAddress): Boolean {
        return oldItem == newItem
    }

    override fun areItemsTheSame(oldItem: FavoriteAddress, newItem: FavoriteAddress): Boolean {
        return oldItem == newItem
    }
}

class AddressViewHolder(val binding : ListItemAddressBinding) : RecyclerView.ViewHolder(binding.root) {

    fun bind() {
        with(binding) {
            executePendingBindings()
        }
    }

}